package com.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Class;

@Mapper
public interface ClassMapper extends BaseMapper<Class> {
    
    @Select("SELECT * FROM classes WHERE teacher_id = #{teacherId}")
    List<Class> findByTeacherId(@Param("teacherId") Long teacherId);
    
    @Select("SELECT * FROM classes WHERE invite_code = #{inviteCode}")
    Class findByInviteCode(@Param("inviteCode") String inviteCode);
    
    @Select("SELECT c.* FROM classes c " +
            "JOIN class_students cs ON c.id = cs.class_id " +
            "WHERE cs.student_id = #{studentId} AND cs.status = 'active'")
    List<Class> findByStudentId(@Param("studentId") Long studentId);
} 